package corej.course.net;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class TestPoemPrint {
    private static String FILE = "D:\\WorkZone\\lab\\TestJava\\src\\com\\jsun\\javase\\corepackage\\io\\testdir\\poem.txt";

    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception {

        List list = new ArrayList();
        FileInputStream fis = new FileInputStream(FILE);
        InputStreamReader ir = new InputStreamReader(fis);
        BufferedReader in = new BufferedReader(ir);
        String s;

        while ((s = in.readLine()) != null) {
            list.add(s);
        }
        in.close();

        int rows = list.size();
        s = (String) list.get(0);
        int cols = s.length();

        FileOutputStream fos = new FileOutputStream("poem2.txt");
        PrintWriter out = new PrintWriter(fos);

        for (int i = 0; i < cols; i++) {
            for (int j = rows - 1; j >= 0; j--) {
                String str = (String) list.get(j);
                char c = str.charAt(i);
                out.print(c);
            }
            out.println();
        }
        out.close();
    }

}
